package cn.ad.server.web.servlet;

import cn.ad.server.common.utils.SpringContextUtils;
import cn.ad.server.web.servlet.v2.RestPathFilter;
import cn.ad.server.web.spring.service.actions.WinnoticeRequestAction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 
 * @deprecated 原广告请求处理Servlet框架将不推荐使用，统一采用v2包下的处理方式，请求入口参考{@link RestPathFilter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)}
 */
@WebServlet("/win-notice.html")
@Deprecated
public class WinNoticeServlet extends AbstractAdServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5398123000285635440L;
	
	private Logger logger = LoggerFactory.getLogger(AbstractAdServlet.class);
	
	public WinnoticeRequestAction getWinnoticeAction(){
		return SpringContextUtils.getBean(WinnoticeRequestAction.class);
	}

	@Override
	void doService(HttpServletRequest request, HttpServletResponse response) {
		try {
			request.getRequestDispatcher("/v2/winotice/ch/1").forward(request, response);
		} catch (ServletException e) {
			logger.error("ServletException", e);
		} catch (IOException e) {
			logger.error("IOException", e);
		}
		return;
		
		
//		WinNoticePresentation wnp = null;
//		
//		try {
//			WinNoticeCommand wnc = new WinNoticeCommand();
//			WebUtils.convetGetRequestParam(request, wnc);
//			String ip = IPUtils.parseIp(request);
//			wnc.setIp(ip);
//			wnc.setUa(request.getHeader("user-agent"));
//			wnp = getWinnoticeAction().makeWinNotice(wnc);
//
//		} catch (Exception e) {
//			logger.error("/win-notice ERROR - {}", e);
//		} finally {
//			adService.unbond();
//			loggerService.logWinNotice(wnp);
//		}
	}

}
